<template>
	<view class="container">
		<navigateV/>
		<!-- 抽奖背景图 -->
		<view class="container-bg" @click="$com.navTo('/pages/bargain/bargain',false,{})">
			<image :src="homeInfo.images[0]" mode="widthFix"></image>
		</view>
		<view  class="container-btn" v-if="homeInfo.images">
			<view class="active-btn" @click="$com.navTo('/pages/bargain/bargain',false,{})">
					点击上方图片参与
			</view>
		</view>
	</view>
</template>

<script>
	import navigateV from './components/navigate-red.vue';
	export default {
		data() {
			return {
				paddingTop:0,
				windowHeight:0,
				homeInfo:{
					images:[]
				},
				showBtn:true,
				scrollTimeout:''
			}
		},
		components:{
			navigateV
		},
		onLoad(e) {
			var _this = this;
			uni.getSystemInfo({
				success: function (res) {
					_this.paddingTop = res.statusBarHeight;
					_this.windowHeight = res.windowHeight
				}
			});
		},
		onShow(){
			this.getAppInfo();
		},
		onPageScroll() {
			this.showBtn = false
			clearTimeout(this.scrollTimeout);
			this.scrollTimeout = setTimeout(() => {
			    this.showBtn = true
			}, 200);
		},
		onShareAppMessage(){
			return this.getShareInfo();
		},
		onShareTimeline(){
			return this.getShareInfo();
		},
		methods: {
			getAppInfo(){
				var _this = this;
				var param = {};
				
				this.$com.wxLogin(function(){
					_this.$appData.app.getAppInfo(param, function(resp){
						_this.$com.setData('app', resp.data);
						_this.homeInfo = resp.data
					});
				},function(){
					_this.$appData.app.getAppInfo(param, function(resp){
						_this.$com.setData('app', resp.data);
						_this.homeInfo = resp.data
					});
				})
				this.$com.getDeviceHeight()
			},
			getShareInfo(){
				var app = this.$com.getData('app');
				var query = {
					invite_code:this.$com.getData('invite_code'),
					app_id:this.$com.getData('app_id'),
				};
				
				var title = app.share_title;
				var imageUrl = app.share_image;
				var path = this.$com.buildQuery('/'+this.$com.getPagePath(), query);
				
				var data = {title:title, imageUrl:imageUrl, path:path};
				console.log(data);
				return data;
			},
			
		}
	}
</script>

<style>
page{background-color: #790001;}

.container-bg {width: 100%;min-height: 90vh;box-sizing: border-box;}
.container-bg image{width: 100%;}
.active-btn{width: 690rpx;border-radius: 50rpx;text-align: center;font-size: 30rpx;font-weight: bold;margin-bottom: 80rpx;margin: 0 auto 60rpx;color: white;font-size: 32rpx}
</style>
